﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using XZL.GM.Bll;
using XZL.GM.Dal;

public partial class Account_ExpenseList : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            txtAccountStart.Text = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd");
            txtAccountEnd.Text = DateTime.Now.ToString("yyyy-MM-dd");

        }
    }

    private void BindDate()
    {
        DateTime accountStart = new DateTime();
        DateTime accountEnd = new DateTime();
        try
        {
            accountStart = Convert.ToDateTime(txtAccountStart.Text);
            accountEnd = Convert.ToDateTime(txtAccountEnd.Text);
            accountEnd = accountEnd.AddDays(1);
        }
        catch (Exception ex)
        {
            lblWarn.Text = "请输入正确的日期格式！";
            return;
        }
        string phone = txtPhone.Text.Trim();
        if (phone.Length != 11)
        {
            lblWarn.Text = "请输入正确的手机号！";
            return;
        }
        Proc_UserInfo_SelectUserInfoByPhoneResult user= UserInfoBiz.UserPhone(phone);
        int type = Convert.ToInt32(ddlType.SelectedValue);
        double? amount = 0;
        int? userCount = 0;
        switch (type)
        {
            case 1:
                gridList.DataSource = AccountInfo.GetUserExpense(user.UserID,accountStart,accountEnd,ref amount);
                break;
            case 2:
                gridList.DataSource = AccountInfo.GetPromoteExpense(user.UserID, accountStart, accountEnd, ref amount,ref userCount);
                break;
            case 3:
                gridList.DataSource = AccountInfo.GetTeamExpense(user.UserID, accountStart, accountEnd, ref amount, ref userCount);
                break;
        }
        gridList.DataBind();
    }

    protected void btnSelect_Click(object sender, EventArgs e)
    {
        BindDate();
        
    }

    protected void netPager_PageChanged(object sender, EventArgs e)
    {
        BindDate();
    }
}